# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Jeremy "Ichimonji10" Audet <ichimonji10 at gmail dot com>
# Contributor: pumpkin <pumpkin at mailoo dot org>
# Contributor: Vsevolod Balashov <vsevolod at balashov dot name>
export CHECKFUNC=1

pkgname=gunicorn
pkgver=20.1.0
pkgrel=9
pkgdesc='WSGI HTTP Server for UNIX'
arch=('any')
url='https://gunicorn.org/'
license=('MIT')
depends=('python')
optdepends=('python-eventlet: For asynchronous request handling with eventlet.'
            'python-gevent: For asynchronous request handling with gevent.'
            'python-tornado: For asynchronous request handling with tornado.'
            'python-setproctitle: For process renaming.')
checkdepends=('python-aiohttp' 'python-coverage' 'python-pytest' 'python-pytest-cov'
              'python-eventlet' 'python-gevent' 'python-six')
source=("$pkgname-$pkgver.tar.gz::https://github.com/benoitc/$pkgname/archive/$pkgver.tar.gz"
        "$pkgname-eventlet-0.30.3.patch::https://github.com/benoitc/$pkgname/commit/6a8ebb4844b2.patch"
        "$pkgname-use-importlib.patch::https://github.com/benoitc/$pkgname/pull/2963/commits/3dc8ee5822191030feddf0ca925129a71bfb3166.patch")
sha512sums=('4fd905f62adc30e044cf2a56a1a77e14bc633258267d6bfbd4f6a68494f93f377e9fb9ed94fab7f11f9d7813857a680974a88c4b6bf97d4f1b74792a81810111'
            'b9c11eab4725a05fffc21b74636518674139d458eb7267729cfbad5f96470600396f71faa1027160dd51e610d74ff785fc03e2d661837808062328a66d6a0442'
            'c617be6ba45b5c0731089c4204176c4677536ddd054303774353f3a6d43e7ec032e1afdad3465167b508cdf49590d11e065295417ac86c1177fc6c40e8997a26')

prepare() {
  cd gunicorn-$pkgver
  sed -e 's/==/>=/' -e 's/,<.*$//' -i requirements_test.txt

  # https://github.com/benoitc/gunicorn/pull/2581
  patch -Np1 -i ../$pkgname-eventlet-0.30.3.patch
  patch -Np1 -i ../$pkgname-use-importlib.patch
}

build() {
  cd gunicorn-$pkgver
  python setup.py build
}

check() {
  cd gunicorn-$pkgver
  python -m pytest
}

package() {
  cd gunicorn-$pkgver
  python setup.py install --root="$pkgdir" --prefix=/usr --optimize=1
  install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
